﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using LinFu.IoC;
using LinFu.IoC.Configuration;
using LinFu.IoC.Configuration.Interfaces;
using LinFu.IoC.Interfaces;
using LinFu.IoC.Configuration;
using LinFu.Reflection;

namespace CoreEx.DynamicInvoker.Implementation
{

    [LoaderPlugin]
    public class ContainerPlugin : IContainerPlugin
    {
        private bool _initialized = false;
        #region ILoaderPlugin<IServiceContainer> Members

        public void BeginLoad(IServiceContainer target)
        {
           
        }

        public void EndLoad(IServiceContainer target)
        {                        
            if (_initialized)
                return;
            if (!target.Contains(typeof(IMethodFinder<MethodBase>)))
                target.Inject<IMethodFinder<MethodBase>>().Using(() => new MethodFinder<MethodBase>()).AsSingleton();
            _initialized = true;
        }

        #endregion
    }
}
